import java.util.ArrayList;
import java.util.List;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/5/19
 * \* Time: 19:54
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 二叉树的中序遍历 {
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int val){
            this.val=val;
        }
    }
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res=new ArrayList<>();
        dfs(res,root);
        return res;
    }

    private void dfs(List<Integer> res,TreeNode root){
        if(root==null){
            return;
        }
        dfs(res,root.left);
        res.add(root.val);
        dfs(res,root.right);
    }


}